package com.frxuexi.shop.viewmodel

import com.frxuexi.lib_base.http.ShopApiService
import com.frxuexi.lib_base.mvi.BaseViewModel
import com.frxuexi.lib_base.mvi.RequestType
import com.frxuexi.shop.intent.OrderIntent
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class OrderViewModel @Inject constructor(val apiService: ShopApiService):BaseViewModel<OrderIntent>(){
    override fun handlerIntent(it: OrderIntent) {
        when(it){
            is OrderIntent.getMyOrder->{
                httpRequest(apiService.getMyOrder(it.type,it.limit,it.page))
            }
            is OrderIntent.payOrder->httpRequest(apiService.payOrder(toBody(it.map)),RequestType.PAY)
        }
    }
}